/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:岁亮亮
 * Date:2024-01-10
 * TIME:17:28
 */
public class fan<T> {//泛型机制
    //public T[] t=new T[];没有明确数组的类型T是未知的;
    //public T t=new T();因为T的未知不知道有没有构造其T的构造方法
    public Object[] objects=new Object[10];

    public T getObjects(int pos) {
        return (T)objects[pos];
    }

    public void setObjects(int pos,T val) {
         objects[pos]=val;
    }

    public static void main(String[] args) {
        fan<Integer> fan=new fan<>();

    }
}
class MyArrat<T extends Number>{//泛型的上界  其T约束为必须是Number或者是它的子类


    public static void main(String[] args) {
        MyArrat<Integer> myArrat=new MyArrat<>();
    }
}
class MyArray<T extends Comparable<T>>{//约束T必须是实现了的comparable的接口
    public T findmaxvalue(T[] array){
        T max=array[0];
        for (int i = 0; i < array.length; i++) {
            if(max.compareTo(array[i])<0 ){
                max=array[i];
            }
        }
        return max;
    }


    public static void main(String[] args) {

        Integer[] integer={1,2,4,3};
        MyArray<Integer> myArrat=new MyArray<>();
        System.out.println(myArrat.findmaxvalue(integer));
    }
}